import { Config, Inject, Provide } from '@midwayjs/decorator';
import { BaseService, CoolCommException } from '@cool-midway/core';
import { MangoRequestService } from './request';

/**
 * 城市
 */
@Provide()
export class MangoCityService extends BaseService {
  @Inject()
  mangoRequestService: MangoRequestService;

  @Config('module.mango')
  coolConfig;

  /**
   * 获取全国所有城市
   */
  async getAll() {
    const url = '/api/6214598156852';
    try {
      return await this.mangoRequestService.post(url);
    } catch (error) {
      throw new CoolCommException(error.message);
    }
  }
  /**
   * 获取全国所有城市
   */
  async getRegionByCityId(id) {
    const url = '/api/6216f72542aaf';
    try {
      return await this.mangoRequestService.post(url, {
        city_id: id,
      });
    } catch (error) {
      throw new CoolCommException(error.message);
    }
  }
}
